package com.mindata.blockchain.core.manager;

import com.mindata.blockchain.core.event.ClientRequestEvent;
import com.mindata.blockchain.socket.packet.BlockPacket;
import com.mindata.blockchain.socket.packet.PacketType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

/**
 * User: jasperxgwang
 * Date: 2018-7-13 10:22
 */
@Service
@Slf4j
public class ClientRequestManager {

    @Order(1)
    @EventListener(ClientRequestEvent.class)
    public synchronized void clientRequest(ClientRequestEvent event) {
        BlockPacket blockPacket = event.getSource();
        PacketType packetType = PacketType.fromValue(blockPacket.getType());
        log.info("发起请求消息 type:{} packet:{}", packetType.getValue(), blockPacket);
    }
}
